{-# OPTIONS -Wall #-}

--------------------------------------------------------------------------------
-- |
-- Module      :  WumpusExpr.VarId
-- Copyright   :  (c) Stephen Tetley 2012
-- License     :  BSD3
--
-- Maintainer  :  stephen.tetley@gmail.com
-- Stability   :  unstable
-- Portability :  GHC
--
-- Variable ids annotated with type and declaration site 
-- (local or global).
--
-- Declaration sites are needed to generate names. 
--
--------------------------------------------------------------------------------

module WumpusExpr.VarId
  (
    VarId(..)
  , varName
  , varType
  , ppVarId
  , ppVarIdT
  
  ) where


import WumpusExpr.Types

import Text.PrettyPrint.HughesPJ                -- package: pretty


-- Should VarId and PrimId be coalesced to different 
-- constructors of the same type?



-- | VarId - synthetic id - changed during alpha renaming
-- PrimId - immutable.
--
data VarId = SynthId Int Type   
           | PrimId  String Type
  deriving (Eq,Ord,Show)

varName :: VarId -> String
varName (SynthId i _) = 'a' : show i
varName (PrimId s _)  = s

varType :: VarId -> Type
varType (SynthId _ t) = t
varType (PrimId _ t)  = t

ppVarId :: VarId -> Doc
ppVarId = text . varName

ppVarIdT :: VarId -> Doc
ppVarIdT v = text (varName v) <+> text "::" <+> ppType (varType v)


